package com.literature.search.core.utils;

/**
 * @ClassName RedisKeyUtil
 * @Description TODO
 * @Author abin
 * @Date 2023/3/3 15:57
 * @Version 1.0
 */
public class RedisKeyUtils {

    private static final String SPLIT = ":";

    private static final String SEARCH = "search";

    private static final String SEARCH_HOT_WORD = "searchHotWord";

    private static final String VIEW = "view";

    private static final String DOWNLOAD = "download";

    private static final String UPDATE_FILE_LIST = "updateFileList";

    private static final String TOP_RANKING = "topRanking";


    //用户搜索记录
    //search:userId -> 搜索关键字
    public static String getSearchHistoryKey(String userId){
        return SEARCH + SPLIT + userId;
    }

    //热搜关键词
    public static String getSearchHotWordKey(){
        return SEARCH_HOT_WORD;
    }

    //浏览量
    public static String getViewKey(){
        return VIEW;
    }

    //下载量
    public static String getDownloadKey(){
        return DOWNLOAD;
    }

    //记录有点赞，收藏，下载和浏览需要更新的文件Id
    public static String getUpdateFileKey(){
        return UPDATE_FILE_LIST;
    }

    //热门文档排行
    public static String getTopRankingKey(){
        return TOP_RANKING;
    }

    public static String getHistoryKeywordCounterKey(String userId){
        return "Document" + SPLIT  + "HistoryKeyword" + SPLIT + "Counter" + SPLIT + userId;
    }

    /**
     *
     保存用户点赞内容数据的key
     * @date 2021/9/26 14:44
     */
    public static final String MAP_KEY_USER_LIKED = "MAP_USER_LIKED";

    /**
     *
     保存内容被点赞数量的key
     */
    public static final String MAP_KEY_USER_LIKED_COUNT = "MAP_USER_LIKED_COUNT";

    /**
     *
     保存用户收藏内容数据的key
     * @date 2021/9/26 14:44
     */
    public static final String MAP_KEY_USER_COLLECTED = "MAP_USER_COLLECTED";

    /**
     *
     保存内容被收藏数量的key
     */
    public static final String MAP_KEY_USER_COLLECTED_COUNT = "MAP_USER_COLLECTED_COUNT";

    /**
     * 拼接被点赞的内容id和点赞的人的id作为key。格式 222222:333333
     * @param fileId 被点赞的内容 id
     * @param userId 点赞的人的id
     * @return
     */
    public static String getLikedKey(String fileId, String userId){
        return fileId + SPLIT + userId;
    }

    /**
     * 拼接被收藏的内容id和点赞的人的id作为key。格式 222222:333333
     * @param fileId 被点赞的内容 id
     * @param userId 点赞的人的id
     * @return
     */
    public static String getCollectedKey(String fileId, String userId){
        return fileId + SPLIT + userId;
    }

}
